<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="timeentry" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{timeentryHome.managed ? 'Edit' : 'Add'} Timeentry</f:facet>


            <s:decorate id="timeentryidField" template="layout/edit.xhtml">
                <ui:define name="label">Timeentryid</ui:define>
                <h:inputText id="timeentryid"
                       required="true"
                          value="#{timeentryHome.instance.timeentryid}"
                           size="29">
                    <a:support event="onblur" reRender="timeentryidField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>




            <s:decorate id="startdatetimeField" template="layout/edit.xhtml">
                <ui:define name="label">Startdatetime</ui:define>
                <rich:calendar id="startdatetime"
                       required="true"
                          value="#{timeentryHome.instance.startdatetime}" datePattern="MM/dd/yyyy" />
            </s:decorate>


            <s:decorate id="enddatetimeField" template="layout/edit.xhtml">
                <ui:define name="label">Enddatetime</ui:define>
                <rich:calendar id="enddatetime"
                       required="true"
                          value="#{timeentryHome.instance.enddatetime}" datePattern="MM/dd/yyyy" />
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{timeentryHome.persist}"
                       disabled="#{!timeentryHome.wired}"
                       rendered="#{!timeentryHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{timeentryHome.update}"
                       rendered="#{timeentryHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{timeentryHome.remove}"
                      immediate="true"
                       rendered="#{timeentryHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Timeentry.xhtml"
                rendered="#{timeentryHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty timeentryFrom ? 'TimeentryList' : timeentryFrom}.xhtml"
                rendered="#{!timeentryHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Job *" labelClass="required">
    <div class="association" id="jobParent">

        <h:outputText value="There is no job associated with this timeentry."
                   rendered="#{timeentryHome.instance.job == null}"/>

        <rich:dataTable var="_job"
                   value="#{timeentryHome.instance.job}"
                rendered="#{timeentryHome.instance.job != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="jobTable">
            <h:column>
                <f:facet name="header">Jobname</f:facet>
                <h:outputText value="#{_job.jobname}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{timeentryHome.instance.job != null ? 'changeParent' : 'selectParent'}" value="#{timeentryHome.instance.job != null ? 'Change' : 'Select'} job"
                       view="/JobList.xhtml">
                <f:param name="from" value="TimeentryEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Person *" labelClass="required">
    <div class="association" id="personParent">

        <h:outputText value="There is no person associated with this timeentry."
                   rendered="#{timeentryHome.instance.person == null}"/>

        <rich:dataTable var="_person"
                   value="#{timeentryHome.instance.person}"
                rendered="#{timeentryHome.instance.person != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="personTable">
            <h:column>
                <f:facet name="header">Personid</f:facet>
                <h:outputText value="#{_person.personid}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Firstname</f:facet>
                <h:outputText value="#{_person.firstname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Lastname</f:facet>
                <h:outputText value="#{_person.lastname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Userpassword</f:facet>
                <h:outputText value="#{_person.userpassword}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{timeentryHome.instance.person != null ? 'changeParent' : 'selectParent'}" value="#{timeentryHome.instance.person != null ? 'Change' : 'Select'} person"
                       view="/PersonList.xhtml">
                <f:param name="from" value="TimeentryEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Feedbacks">
        <h:form styleClass="association" id="feedbacksChildren">

            <h:outputText value="There are no feedbacks associated with this timeentry."
                       rendered="#{empty timeentryHome.feedbacks}"/>

            <rich:dataTable value="#{timeentryHome.feedbacks}"
                           var="_feedback"
                      rendered="#{not empty timeentryHome.feedbacks}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="feedbacksTable">
                <rich:column sortBy="#{_feedback.feedbackid}">
                    <f:facet name="header">Feedbackid</f:facet>
                    <h:outputText value="#{_feedback.feedbackid}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_feedback.text}">
                    <f:facet name="header">Text</f:facet>
                    <h:outputText value="#{_feedback.text}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{timeentryHome.managed}" id="feedbacks">
        <div class="actionButtons">
            <s:button id="addfeedback"
                   value="Add feedback"
                    view="/FeedbackEdit.xhtml"
             propagation="none">
                 <f:param name="timeentryTimeentryid"
                         value="#{timeentryHome.instance.timeentryid}"/>
                 <f:param name="feedbackFrom" value="Timeentry"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
